<%-- 
    Document   : Home
    Created on : May 15, 2014, 11:04:47 AM
    Author     : root
    Pagina  : pagina 3
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Bem Vindo</title>
        <style>
            table{
                margin-right: auto;
                margin-left: auto;
            }
            h1{
            text-align: center;
            }
            nav ul li{
            padding: 0;
            margin: 100px 20px 0 0;
            display: inline;
            }  
        </style>
    </head>
    <body>
        
        <jsp:useBean id="usuario" class="model.Usuario" scope="session"/>
        <jsp:useBean id="productsList" type="java.util.ArrayList" scope="session"/>
        
        <h1>Bem Vindo <c:out value="${usuario.nome}"/></h1>
        
        <nav>
            <ul>
                <li><a href="ServletCarrinho?acao=exibe">Carrinho de compras</a></li>                
                <li><a href="ServletCadastro?acao=editarCadastro">Editar dados de usuario</a></li>
                <c:if test="${usuario.tipo == 'admin'}">
                    <li><a href="admin/cadastroproduto.jsp">Cadastro de produtos</a></li>
                    <li><a href="admin/estoque.jsp">Gerenciar estoque</a></li>
                </c:if>
                <li><a href="ServletCarrinho?acao=finaliza">Logout</a></li>

            </ul>
        </nav>
        
        <table border="1">
            <tr><th>Nome</th><th>Categoria</th><th>Preço</th><th>Detalhes</th></tr>
            <c:forEach var="pro" items="${productsList}">
                <c:if test="${pro.qtdEmEstoque > 0}">
                    <c:if test="${pro.status == true}">
                    <tr><td>${pro.nome}</td><td>${pro.categoria}</td><td>R$ ${pro.getValorDouble()}</td>
                            <td><a href="ServletProduto?prodId=${pro.id}&acao=exibe">Detalhes desse produto</a></td></tr>
                    </c:if>
                </c:if>     
            </c:forEach>       
            
        </table>
        
       
    </body>
</html>
